﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DL;
using Model;


namespace DokterAfspraken.PatientPages
{
    public partial class PatientLogin : System.Web.UI.Page
    {
        protected void Page_PreInit(object sender, EventArgs e)
        {
            Model.DataModelManager manager = new DataModelManager();
            HttpCookie myCookie = new HttpCookie("UserSettings");
            myCookie = Request.Cookies["UserSettings"];
            if (myCookie != null)
            {
                // System.Web.HttpContext.Current.Response.Write(manager.getAccountType(myCookie["dokterspraktijk_username"].ToString()));
                if (manager.getAccountType(myCookie["dokterspraktijk_username"].ToString()) == "Administrator")
                {
                    Response.Redirect("../AdminPages/Adminkeuzescherm.aspx");
                }
                else if (manager.getAccountType(myCookie["dokterspraktijk_username"].ToString()) == "Arts")
                {
                    Response.Redirect("../DoctorPages/Dokterkeuzescherm.aspx");
                }
                else if (manager.getAccountType(myCookie["dokterspraktijk_username"].ToString()) == "Patient")
                {
                    Response.Redirect("../PatientPages/PatientAgenda.aspx");
                }

            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            LoginFactory myLoginFactory = new LoginFactory();
            myLoginFactory.Inloggen(txtbUsername.Text, txtbPaswoord.Text, chbCookie.Checked);

            int ID = int.Parse(Request.QueryString["ID"]);
            int PraktijkID = int.Parse(Request.QueryString["PraktijkID"]);
            System.Web.HttpContext.Current.Response.Redirect("../PatientPages/PatientAgenda.aspx?ID=" + ID + "&PraktijkID=" + PraktijkID);
        }

        protected void btn_AccountMaken_Click(object sender, EventArgs e)
        {

            Response.Redirect("PatientAccountAanmaak.aspx");
        }
    }
}